package com.market.controller.admin;

import com.market.bean.MarketStorage;
import com.market.bean.common.BasePageInfo;
import com.market.bean.common.BaseRespVo;
import com.market.bean.common.CommonData;
import com.market.bean.vo.admin.AdminStorageCreateVo;
import com.market.service.admin.AdminStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 系统管理模块-对象存储
 * @since 2022/12/29 10:59
 * @author 2731235517@qq.com 谢畅
 */
@RestController
@RequestMapping("admin/storage")
public class AdminStorageController {

    @Autowired
    AdminStorageService adminStorageService;

    @RequestMapping("list")
    public BaseRespVo list(BasePageInfo basePageInfo,String key, String name) {
        CommonData<MarketStorage> commonData = adminStorageService.list(basePageInfo,key,name);
        return BaseRespVo.ok(commonData);
    }

    @RequestMapping("create")
    public BaseRespVo create(MultipartFile file) {
        AdminStorageCreateVo adminStorageCreateVo = adminStorageService.create(file);
        return BaseRespVo.ok(adminStorageCreateVo);
    }

    @RequestMapping("update")
    public BaseRespVo update(@RequestBody MarketStorage storage) {
        MarketStorage marketStorage = adminStorageService.update(storage);
        return BaseRespVo.ok(marketStorage);
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody MarketStorage storage) {
        MarketStorage marketStorage = adminStorageService.delete(storage);
        return BaseRespVo.ok(marketStorage);
    }
}
